package com.app.service.impl;

import com.app.dao.mysql.QmDataMapper;
import com.app.domain.JsonResult;
import com.app.domain.QmData;
import com.app.domain.YjData;
import com.app.service.QmDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class QmDataServiceImpl implements QmDataService {
    @Autowired
    private QmDataMapper qmDataMapper;

    @Override
    public JsonResult findAll(String device_code,Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<QmData> qmData = qmDataMapper.findAll(device_code);
        PageInfo pageInfo = new PageInfo(qmData);
        return JsonResult.success(pageInfo.getList(), pageInfo.getTotal());

    }

    @Override
    public String ConditionUpdate(String id, String field, String value) {
        String s;
        try {
            qmDataMapper.ConditionUpdate(id, field, value);
            s = "修改成功";
        } catch (Exception e) {
            s = "修改失败";
            e.printStackTrace();
        }
        return s;
    }
}
